<?php

/**
 * Validate class allows the use of a number of validation
 * methods, which throw exceptions if the validation does 
 * not pass
 * 
 */
class Validate{
	
	/**
	 * validates that the passed variable is not null
	 * 
	 * @throws Exception, if variable is null
	 * @return boolean
	 */
	// TODO: see if PHP5 supports overloading instead of
	// using optional parameters
	public static function notNull($input, $msg = null){
		
		// exception message
		if($msg == null)
			$msg =  "field was null, when validating for not null";
		
		if($input == null)
			throw new NullPointerException($msg);
			
		return true;
	}
	
	public static function nonZeroLength($input, $msg = null){
		
		// exception message
		if($msg == null)
			$msg =  "field was null, when validating for not null";

		if(strlen($input) < 1){
			throw new Exception($msg);
		}
		
		return true;
	}
	
}
?>